home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 55375 / 55375.xpi / chrome / chromeFiles / content / bindings / btsearchbar.xml < prev    next >
Encoding:
Text File  |  2009-11-15  |  2.0 KB  |  65 lines

  1. <bindings
  2.       xmlns="http://www.mozilla.org/xbl"
  3.       xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  4.       xmlns:xbl="http://www.mozilla.org/xbl">
  5.  
  6.   <binding id="btsearchbar">
  7.     <resources>
  8.       <stylesheet src="btsearchtextbox.css"/>
  9.     </resources>
  10.     <content>
  11.       <xul:textbox class="bt_searchbar_textbox"
  12.                    anonid="textbox"
  13.                    type="autocomplete">
  14.       </xul:textbox>
  15.       <xul:button class="bt_searchbar_button"
  16.                   anonid="button">
  17.       </xul:button>
  18.       
  19.     </content>
  20.     
  21.     <handlers>
  22.       <handler event="command"><![CDATA[
  23.         switch (event.originalTarget.getAttribute("anonid")) {
  24.           case "button":
  25.             this.handleSearchCommand(event);
  26.             break;
  27.         }
  28.        ]]>
  29.       </handler>
  30.     </handlers>
  31.     
  32.     <implementation>
  33.       <method name="handleSearchCommand">
  34.         <parameter name="event"/>
  35.         <parameter name="text"/>
  36.         <body><![CDATA[
  37.           if (!text) {
  38.             text = document.getAnonymousElementByAttribute(this, "anonid", "textbox").value;
  39.           }
  40.           var searchSvc = Components.classes["@mozilla.org/browser/search-service;1"]
  41.                                     .getService(Components.interfaces.nsIBrowserSearchService);
  42.           var yahooEngine = searchSvc.getEngineByName("Yahoo!");
  43.           if (yahooEngine) {
  44.             var submission = yahooEngine.getSubmission(text, null);
  45.             openUILinkIn(submission.uri.spec + "L", "tab", null, submission.postData);
  46.           }
  47.         ]]></body>
  48.       </method>
  49.  
  50.     </implementation>
  51.   </binding>
  52.  
  53.   <binding id="bt-searchbar-textbox"
  54.       extends="chrome://global/content/bindings/autocomplete.xml#autocomplete">
  55.     <implementation>
  56.       <method name="onTextEntered">
  57.         <parameter name="event"/>
  58.         <body><![CDATA[
  59.           document.getBindingParent(this).handleSearchCommand(event, this.value);
  60.         ]]></body>
  61.       </method>
  62.     </implementation>
  63.   </binding>
  64. </bindings>
  65.